package com.glela.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.glela.order.model.CommissionManage;
import com.glela.order.service.CommissionManageService;
import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.request.RequestUserModel;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.model.response.ResponseResultModel;

/**
 * @author chengzhequan
 * @2016年10月25日
 */
@Controller
@RequestMapping("/commissionManage")
public class CommissionManageController {

	private static Logger logger = LoggerFactory.getLogger(OrderController.class);

	@Autowired
	private CommissionManageService CommissionManageService;
	
	/**
	 * 佣金管理
	 * 
	 * @param requestUserSet
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/selectCommissionManage", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> selectCommissionManage(@RequestBody RequestUserModel requestUserModel) {
		try {
			if (requestUserModel.getUserId() == null) {
				// 必传参数未传
				return new ResponseEntity<ResponseBaseModel>(new ResponseBaseModel(ErrorEnum.C29901), HttpStatus.OK);
			}
			CommissionManage commissionManage = CommissionManageService.selectCommissionManage(requestUserModel.getUserId());
			return new ResponseEntity<>(new ResponseResultModel<CommissionManage>(commissionManage), HttpStatus.OK);
		} catch (Exception e) {
			logger.error("佣金管理异常:", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
}
